import { defineStore } from 'pinia';
import helper from "../helper"


const privateroomcart = defineStore({
  id: 'privateroomcart',
  state: () => ({
	cartList:[]
  }),

  actions: {
		addCart(cartInfo){
			this.cartList = this.cartList.concat([cartInfo])
		},
		clearCart(){
			this.cartList = []
		},
		delIndexCart(index){
			helper.showModal({content:`确认移除${this.cartList[index].info.name}房间吗？`}).then( () => {
				this.cartList.splice(index,1)
			}).catch( err => {})
		}
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'privateroomcart-store',
      },
    ],
  },
});

export default privateroomcart;
